package info.batcloud.fanli.core.service;

import com.ctospace.archit.common.pagination.Paging;
import com.ctospace.archit.common.pagination.PagingParam;
import info.batcloud.fanli.core.dto.AgentDTO;
import info.batcloud.fanli.core.dto.CityAgentDTO;
import info.batcloud.fanli.core.dto.DistrictAgentDTO;
import info.batcloud.fanli.core.enums.AgentStatus;
import info.batcloud.fanli.core.enums.AgentType;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;
import java.util.List;

public interface AgentService {

    Paging<AgentDTO> search(SearchParam param);

    AgentDTO addAgent(AgentAddParam param);

    List<AgentDTO> findAgentByUserId(long userId);

    boolean isAgent(long userId, AgentType agentType);

    CityAgentDTO findCityAgentByCityId(long cityId);

    DistrictAgentDTO findDistrictAgentByDistrictId(long districtId);

    boolean isValid(AgentDTO agent);

    void setStatus(long id, AgentStatus status);

    class AgentAddParam {
        private Long userId;
        private int year;

        public Long getUserId() {
            return userId;
        }

        public void setUserId(Long userId) {
            this.userId = userId;
        }

        public int getYear() {
            return year;
        }

        public void setYear(int year) {
            this.year = year;
        }
    }

    class SearchParam extends PagingParam {

        private String phone;
        private Boolean perpetual;

        private AgentStatus status;

        @DateTimeFormat(pattern = "yyyy-MM-dd")
        private Date startUpdateTime;
        @DateTimeFormat(pattern = "yyyy-MM-dd")
        private Date endUpdateTime;

        private AgentType type;

        public AgentType getType() {
            return type;
        }

        public void setType(AgentType type) {
            this.type = type;
        }

        public AgentStatus getStatus() {
            return status;
        }

        public void setStatus(AgentStatus status) {
            this.status = status;
        }

        public Date getStartUpdateTime() {
            return startUpdateTime;
        }

        public void setStartUpdateTime(Date startUpdateTime) {
            this.startUpdateTime = startUpdateTime;
        }

        public Date getEndUpdateTime() {
            return endUpdateTime;
        }

        public void setEndUpdateTime(Date endUpdateTime) {
            this.endUpdateTime = endUpdateTime;
        }

        public String getPhone() {
            return phone;
        }

        public void setPhone(String phone) {
            this.phone = phone;
        }

        public Boolean getPerpetual() {
            return perpetual;
        }

        public void setPerpetual(Boolean perpetual) {
            this.perpetual = perpetual;
        }
    }

}
